package demo.annotation.method;

import demo.annotation.PersonInfo;

import java.lang.reflect.Field;
import java.lang.reflect.Method;

public class Test {
	// 获取Method上的注解
	public static void main(String[] args) throws ClassNotFoundException {
		Class clazz = Class.forName("demo.annotation.Singer");
		Method[] methods = clazz.getDeclaredMethods();
		for (Method method: methods){
			if(method.isAnnotationPresent(PersonInfo.class)){
				PersonInfo annotation = method.getAnnotation(PersonInfo.class);
				System.out.println("name,age = "+annotation.name()+","+annotation.age());
			}
		}
	}
}
